<style>
    .attrs .input-group{

        cursor: pointer;

    }
</style>
<div class="view-lists " id="attrs">
    <div class="view-title">
        商品规格:
    </div>
    <?php foreach($data as $v):?>
    <div class="filed-list attrs">
        <div class="view-content">
            <div class="col-sm-2 filed-name" data-id="<?php echo $v['id']?>" data-name="<?php echo $v['name']?>">
                <?php echo $v['name']?>:
            </div>
            <?php if($v['attr_values']):?>
            <div class="col-sm-10 filed-input">
                <?php foreach($v['attr_values'] as $val):?>
                    <div class="col-md-2">
                        <label class="input-group goods_attrs" for="attr_<?php echo $val['id']?>">
                            <span class="input-group-addon radius-none">
                                <input type="checkbox" id="attr_<?php echo $val['id']?>" data-attr_id="<?php echo $v['id']?>" name="attrs" data-name="<?php echo $val['name']?>" value="<?php echo $val['id']?>">
                            </span>
                            <div class="form-control radius-none text-center"><?php echo $val['name']?></div>
                        </label>
                    </div>
                <?php endforeach;?>
            </div>
            <?php endif;?>
        </div>
    </div>
    <?php endforeach;?>
</div>
<script>
    var a = ["A","B","C"];
    var b = ["1", "2","3"];
    window.onload = function () {
        var a1 = new objPL(a);//计算数组a的排列组合
        var b1 = new objPL(b);//计算数组b的排列组合
        var str = "";
        var n = 0;
        //a1和b1的排列组合个数就是两者相乘（双层循环）
        for (var i = 0; i < a1.length; i++) {
            for (var j = 0; j < b1.length; j++) {
                str += a1[i] + b1[j] + " ";
                n++;
            }
            str += "";
        }
        document.write("共" + n + "个");
        document.write(str);
    }
    //取数组的排列组合
    function objPL(arr) {
        this.a = arr;
        this.r = [];
        this.n = 0;
        //从M个数里面取N个(递归)
        this.mGetN = function (curIndex, num, curSelect) {
            if (num == 0) {
                this.r[this.n++] = curSelect; return;
            }
            if (this.a.length - curIndex < num) return;
            this.mGetN(curIndex + 1, num - 1, curSelect + this.a[curIndex]);
            this.mGetN(curIndex + 1, num, curSelect);
        }
        for (var i = 1; i <= this.a.length; i++) {
            this.mGetN(0, i, "");
        }
        return this.r;
    }

</script>